package com.relytosoft.mizar.analyze.base.entity.pojo.request.btdl.common;

import com.relytosoft.mizar.analyze.base.entity.pojo.base.BaseAlgoDataReq;
import com.relytosoft.mizar.analyze.base.entity.pojo.dto.AyControlAlarmDto;
import io.swagger.annotations.ApiModel;

import java.time.LocalDateTime;
import java.util.Map;

import static com.relytosoft.mizar.analyze.base.constant.AlarmTypeConstants.ANALYZE_ALARM;

/**
 * @author wss
 * @version 1.0
 * @date 2022/5/16 9:28
 */
@ApiModel("比特大陆公共数据请求")
public class BtdlDataReq extends BaseAlgoDataReq {

    private static final String ALARM_DTO_MSG = "原生数据自定义布控告警";

    /**
     * 构建布控报警对象
     *
     * @param btdlDataReq
     * @return
     */
    public static AyControlAlarmDto buildControlAlarm(BtdlDataReq btdlDataReq) {
        Map<String, String> bigPic = btdlDataReq.getBigPic();
        for (String imageKey : bigPic.keySet()) {
            AyControlAlarmDto ayControlAlarmDto = new AyControlAlarmDto();
            ayControlAlarmDto.setAlarmTypeId(ANALYZE_ALARM);
            ayControlAlarmDto.setTaskId(btdlDataReq.getVideoSliceListObject().getVideoSlice().get(0).getTaskID());
            ayControlAlarmDto.setAlarmImg(bigPic.get(imageKey));
            ayControlAlarmDto.setCameraId(btdlDataReq.getVideoSliceListObject().getVideoSlice().get(0).getDeviceID());
            ayControlAlarmDto.setAlarmTime(LocalDateTime.now());
            ayControlAlarmDto.setRemark(ALARM_DTO_MSG);
            return ayControlAlarmDto;
        }
        return null;
    }

}
